(0, require("../common/component").VantComponent)({
    field: !0,
    classes: [ "input-class", "plus-class", "minus-class" ],
    props: {
        value: null,
        integer: Boolean,
        disabled: Boolean,
        inputWidth: String,
        asyncChange: Boolean,
        disableInput: Boolean,
        min: {
            type: null,
            value: 1
        },
        max: {
            type: null,
            value: Number.MAX_SAFE_INTEGER
        },
        step: {
            type: null,
            value: 1
        }
    },
    computed: {
        minusDisabled: function() {
            return this.data.disabled || this.data.value <= this.data.min;
        },
        plusDisabled: function() {
            return this.data.disabled || this.data.value >= this.data.max;
        }
    },
    watch: {
        value: function(newValue) {
            if ("" !== newValue) {
                var clampedValue = this.range(newValue);
                "number" == typeof clampedValue && +this.data.value !== clampedValue && this.set({
                    value: clampedValue
                });
            }
        }
    },
    data: {
        focus: !1
    },
    created: function() {
        this.set({
            value: this.range(this.data.value)
        });
    },
    methods: {
        onFocus: function(event) {
            this.$emit("focus", event.detail);
        },
        onBlur: function(event) {
            var clampedValue = this.range(this.data.value);
            this.triggerInput(clampedValue), this.$emit("blur", event.detail);
        },
        range: function(inputValue) {
            return inputValue = String(inputValue).replace(/[^0-9.-]/g, ""), Math.max(Math.min(this.data.max, inputValue), this.data.min);
        },
        onInput: function(event) {
            var processedValue = (event.detail || {}).value, newValue = void 0 === processedValue ? "" : processedValue;
            this.triggerInput(newValue);
        },
        onChange: function(direction) {
            if (this.data[direction + "Disabled"]) this.$emit("overlimit", direction); else {
                var stepValue = "minus" === direction ? -this.data.step : +this.data.step, newValue = Math.round(100 * (this.data.value + stepValue)) / 100;
                this.triggerInput(this.range(newValue)), this.$emit(direction);
            }
        },
        onMinus: function() {
            this.onChange("minus");
        },
        onPlus: function() {
            this.onChange("plus");
        },
        triggerInput: function(newValue) {
            this.set({
                value: this.data.asyncChange ? this.data.value : newValue
            }), this.$emit("change", newValue);
        }
    }
});